package easy;

import java.util.Arrays;

/*
976. 三角形的最大周长
 */
public class LeeCode976 {

  public static void main(String[] args) {
    int[] num = new int[]{3,6,2,3};
    System.out.println(new LeeCode976().largestPerimeter(num));
  }

  public int largestPerimeter(int[] nums) {
    Arrays.sort(nums);
    int a = nums.length - 3;
    int b = nums.length - 2;
    int c = nums.length - 1;
    while (a >= 0){
      if (nums[a] + nums[b] > nums[c]){
        return nums[a] + nums[b] + nums[c];
      }
      a--;
      b--;
      c--;
    }
    return 0;
  }


}
